package com.huihua.it.enums;

public enum I18nEnum {

    EN_US("en","英文","en_US"),
    ZH_CN("cn","中文简体","zh_CN"),
    ZH_TW("tw","中文繁体","zh_TW"),
    KO_KR("kr","韩文","ko_KR"),
    JA_JP("jp","日文","ja_JP");

    private String key;
    private String i18nDes;
    public String code;

    public String getCode() {
        return code;
    }
    public String getI18nDes() {
        return i18nDes;
    }
    public String getKey() {
        return key;
    }

    I18nEnum(String code, String i18nDes, String key) {
        this.code = code;
        this.i18nDes = i18nDes;
        this.key = key;
    }

    public static I18nEnum fromValue(String value) {
        if (null == value) {
            return null;
        }
        I18nEnum[] enumObjs = I18nEnum.values();
        for (I18nEnum obj : enumObjs) {
            if (value.equals(obj.code)) {
                return obj;
            }
        }
        return null;
    }

    public static I18nEnum fromKey(String value) {
        if (null == value) {
            return null;
        }
        I18nEnum[] enumObjs = I18nEnum.values();
        for (I18nEnum obj : enumObjs) {
            if (value.equals(obj.key)) {
                return obj;
            }
        }
        return null;
    }
}
